package com.kkb.controller.dataanalysis;

import com.kkb.bean.User;
import com.kkb.service.dataanalysis.ProductAnalysisService;
import com.kkb.vo.BaseResp;
import com.kkb.vo.dataanalysis.req.FileReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author mj
 * @create 2021-04-14 16:48
 * @describe:
 */
@RestController
@RequestMapping("product")
public class ProductAnalysisController {

    @Autowired
    private ProductAnalysisService productAnalysisService;

    /**
     * 查询商品总览
     * @param request
     * @return
     */
    @GetMapping("/productOverview")
    public BaseResp<Map<String,Object>> productOverview(HttpServletRequest request){
//        User user = (User) request.getSession().getAttribute("user");
        try {
            User user = new User();
            user.setUserId(1);
            Map<String,Object> map = productAnalysisService.productOverview(user);
            return new BaseResp<>(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new BaseResp<>("1000",false,"查询失败");
        }
    }

    /**
     * 查询文档商品的效果
     * @param request
     * @return
     */
    @GetMapping("/fileMsg")
    public BaseResp<Map<String,Object>> fileMsg(HttpServletRequest request, FileReq fileReq){
//        User user = (User) request.getSession().getAttribute("user");
        try {
            User user = new User();
            user.setUserId(1);
            Map<String,Object> map = productAnalysisService.fileMsg(user,fileReq);
            return new BaseResp<>(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new BaseResp<>("1000",false,"查询失败");
        }
    }

    /**
     * 查询文集商品的效果
     * @param request
     * @return
     */
    @GetMapping("/fileAnthologyMsg")
    public BaseResp<Map<String,Object>> fileAnthologyMsg(HttpServletRequest request, FileReq fileReq){
//        User user = (User) request.getSession().getAttribute("user");
        try {
            User user = new User();
            user.setUserId(1);
            Map<String,Object> map = productAnalysisService.fileAnthologyMsg(user,fileReq);
            return new BaseResp<>(map);
        } catch (Exception e) {
            e.printStackTrace();
            return new BaseResp<>("1000",false,"查询失败");
        }
    }
}
